/*
 * $Id: Diff.java 23 2002-09-29 13:59:30Z bpruessmann $
 *
 * Copyright (c) 2001 Boris Pruessmann and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Common Public License v0.5
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors:
 *    Boris Pruessmann - Initial implementation.
 */
package net.sourceforge.p4eclipse.internal.core.api;

import java.util.ArrayList;
import java.util.List;

import net.sourceforge.p4eclipse.core.api.ClientUser;
import net.sourceforge.p4eclipse.core.api.IPerforceCommand;
import net.sourceforge.p4eclipse.ui.PerforceUIPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;

/**
  * ClientUser object for the 'p4 diff' command.
  * 
  * @version 	$Revision: 23 $
  * @author		<a href="mailto:bpruessmann@users.sourceforge.net">Boris Pruessmann</a>
  */
public class Diff extends ClientUser implements IPerforceCommand 
{
	// ------------------------------------------------------- Private Variables
	
	/** Stores the command's status. */
	private MultiStatus status;
	/** Stores the result of the 'p4 resolved' operation. */
	private List result = new ArrayList();

	// ------------------------------------------- Public Static Factory Methods
	
	/* Convenience method for creating instances of 'Resolved'. */
	public static final Diff newInstance()
	{
		MultiStatus status = 
			new MultiStatus(PerforceUIPlugin.ID, IStatus.OK, "", null);
			
		return new Diff(status);
	}

	// ---------------------------------------------------- Private Constructors
	
	/** Constructor for Resolved. */
	private Diff(MultiStatus status)
	{
		super(status);
		this.status = status;
	}

	// ---------------------------------------------------------- Public Methods
	
	/** @return the result of 'p4 resolved'. */
	public String[] getResult()
	{
		return (String[])result.toArray(new String[result.size()]);
	}

	// -------------------------------------------- Public Methods (IClientUser)
	
	/**
	  * @see IClientUser#outputInfo(char, String)
	  */
	public void outputInfo(char level, String infoString) 
	{
		result.add(infoString);
	}	

	// --------------------------------------- Public Methods (IPerforceCommand)
	
	/**
	  * @see IPerforceCommand#getCommand()
	  */
	public String getCommand() 
	{
		return "diff";                                             //$NON-NLS-1$
	}

	/**
	  * @see IPerforceCommand#getStatus()
	  */
	public IStatus getStatus() 
	{
		return status;
	}

	/**
	  * @see IPerforceCommand#isHidingFromConsole()
	  */
	public boolean isHidingFromConsole() 
	{
		return false;
	}

}
